package teamproject.visualization.gui.visualobjects;

import javax.media.j3d.Appearance;
import javax.media.j3d.RenderingAttributes;

import teamproject.visualization.gui.Visualizer;
import teamproject.visualization.io.ImageProvider;

import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.geometry.Primitive;

public class Package implements VisualObject {

	private Box textureCube;
	private RenderingAttributes ra;
	private Appearance appear;
	private int id;
	private boolean bufferPackage;
	private boolean animatedVisible = false;

	public Package(boolean bufferPackage) {
		this(Visualizer.PACKETSIZE, Visualizer.PACKETSIZE,
				Visualizer.PACKETSIZE, 1, bufferPackage);
	}

	public Package(float x, float y, float z, int id, boolean bufferPackage) {
		this.setId(id);
		this.bufferPackage = bufferPackage;

		ra = new RenderingAttributes();
		ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
		appear = new Appearance();
		appear.setRenderingAttributes(ra);
		appear.setTexture(ImageProvider
				.getImage("/teamproject/visualization/gui/visualobjects/package.jpg"));
		textureCube = new Box(x, y, z, Primitive.GENERATE_TEXTURE_COORDS, appear);
	}

	public Box getBox() {
		return textureCube;
	}

	public int getId() {
		return id;
	}

	public boolean isAnimatedVisible() {
		return animatedVisible;
	}

	public boolean isBufferPackage() {
		return bufferPackage;
	}

	@Override
	public boolean isVisible() {
		return ra.getVisible();
	}

	public void setAnimatedVisible(boolean animatedVisible) {
		this.animatedVisible = animatedVisible;
	}

	public void setBufferPackage(boolean bufferPackage) {
		this.bufferPackage = bufferPackage;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Override
	public void setVisible(boolean visible) {
		ra.setVisible(visible);
	}
}
